package pro.shushi.pamirs.hr.api.pmodel.eam;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTable;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.enums.eam.MmdTypeEnum;
import pro.shushi.pamirs.hr.api.enums.eam.UkCycTypeEnum;
import pro.shushi.pamirs.hr.api.model.eam.*;
import pro.shushi.pamirs.hr.api.model.org.Department;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.annotation.Prop;
import pro.shushi.pamirs.meta.enmu.ModelTypeEnum;

import java.util.List;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@Model.model(EamUkHdMtoolProxy.MODEL_MODEL)
@Model(displayName = "工装保养代理模型",labelFields = {"ukCode"})
@Model.Advanced(type = ModelTypeEnum.PROXY)
@Model.Code(sequence = "SEQ", prefix = "UKM", size = 5, step = 1, initial = 10000)
public class EamUkHdMtoolProxy extends EamUkHd {

    public static final String MODEL_MODEL = "hr.simple.EamUkHdMtoolProxy";


    @Field.Enum(size = 4)
    @Field(displayName = "保养类型", required = true,priority = 3L,defaultValue = "2")
    @UxForm.FieldWidget(@UxWidget(config = {@Prop(name = "constructFun", value = "constructBsMtoolChange")}))
    public UkCycTypeEnum ukCycType;

    // ---------- 工装信息与工装型号信息 ----------------------
    @UxTableSearch.FieldWidget(@UxWidget())
    // 清除工装型号，自动清除mmdName
    @UxForm.FieldWidget(@UxWidget(config = {@Prop(name = "clearFields", value = "mtoolName,mmdCode,mmdName,mmdType"),
            @Prop(name = "constructData", value = "true"), @Prop(name = "constructSubmitType", value = "CURRENT"),
            @Prop(name = "constructFun", value = "constructBsMtoolChange")}))
    @Field.one2one
    @Field.Relation(relationFields = {"orgCode","refCode"}, referenceFields = {"orgCode","mtoolCode"})
    @Field(displayName = "工装编码", required = true, priority = 10L)
    private BsMtool bsMtool;

    @Field.String
    @Field.Related(related = {"bsMtool", "mtoolName"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装名称", priority = 11L)
    private String mtoolName;

    @Field.String
    @Field.Related(related = {"bsMtool", "mmdCode"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装型号编码", priority = 12L)
    private String mmdCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    // 清除工装型号，自动清除mmdName
    @UxForm.FieldWidget(@UxWidget(config = {@Prop(name = "clearFields", value = "mmdName")}))
    @Field.many2one
    @Field.Relation(relationFields = {"orgCode","mmdCode"}, referenceFields = {"orgCode","mmdCode"})
    @Field(displayName = "工装型号", invisible = true)
    private BsMtoolMd bsMtoolMd;

    @Field.String
    @Field.Related(related = {"bsMtoolMd", "mmdName"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装型号名称", priority = 14L)
    private String mmdName;

    @Field.Enum
    @Field.Related(related = {"bsMtoolMd", "mmdType"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装特殊分类", priority = 15L)
    private MmdTypeEnum mmdType;


    // ---------- 工装信息与工装型号信息 ----------------------

    @Field.one2many
    @Field.Relation(relationFields = {"orgCode", "ukCode"}, referenceFields = {"orgCode", "ukCode"})
    @Field(displayName = "保养项明细")
    private List<EamUkDtMtoolProxy> eamUkDtList;

    @Field.one2many
    @Field.Relation(relationFields = {"orgCode", "ukCode"}, referenceFields = {"orgCode", "ukCode"})
    @Field(displayName = "钢网保养张力明细")
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'STENCIL'"))
    private List<EamUkDtTension> eamUkDtTensionList;


    @Field.one2many
    @Field.Relation(relationFields = {"orgCode", "ukCode"}, referenceFields = {"orgCode", "ukCode"})
    @Field(displayName = "刮刀保养平整度明细")
    @UxForm.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'SCRAPER'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.mmdType != 'SCRAPER'"))
    private List<EamUkDtPlaneness> eamUkDtPlanenessList;

}
